package cn.com.headfree.mouldshow.controller;

import cn.com.headfree.base.controller.ExBaseController;
import cn.com.headfree.base.controller.ResultData;
import cn.com.headfree.entity.*;
import cn.com.headfree.entity.isc.User;
import cn.com.headfree.mouldshow.service.HumanDataTempService;
import cn.com.headfree.mouldshow.service.TMouldInfoService;
import cn.com.headfree.mouldshow.vo.TPerformanceScoreVo;
import cn.com.headfree.util.SysDictionaryUtil;
import cn.com.headfree.vo.HeadVo;
import com.alibaba.fastjson.JSON;
import com.gta.edu.sdk.common.dto.Page;
import net.sf.json.JSONArray;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Iterator;
import java.util.List;

/**
 *数据导入模板
 */
@Controller
@RequestMapping(value = "/humanDataTemp", produces = "application/json;charset=UTF-8")
public class HumanDataTempController extends ExBaseController {
	private static final Logger LOG = LogManager.getLogger(HumanDataTempController.class);

	@Autowired
	private HumanDataTempService humanDataTempService;

	@Autowired
	private TMouldInfoService tMouldInfoService;

	@Value("${jbxx}")
	private String jbxx;

	@Value("${xlxx}")
	private String xlxx;

	@Value("${gzjl}")
	private String gzjl;

	@Value("${pxsk}")
	private String pxsk;

	@Value("${grry}")
	private String grry;

	@Value("${jsks}")
	private String jsks;

	@Value("${zjrc}")
	private String zjrc;

	@Value("${zyzg}")
	private String zyzg;

	@Value("${jndj}")
	private String jndj;

	@Value("${dsdt}")
	private String dsdt;

	@Value("${ndjx}")
	private String ndjx;

	@Value("${xscg}")
	private String xscg;

	@Value("${zdbz}")
	private String zdbz;

	@Value("${zlxx}")
	private String zlxx;

	@Value("${jygx}")
	private String jygx;

	@Value("${kjcx}")
	private String kjcx;

	@Value("${ktcg}")
	private String ktcg;
	@Value("${ygld}")
	private String ygld;
	@Value("${gzlg}")
	private String gzlg;
	@Value("${jxjf}")
	private String jxjf;
	/**
	 * 获取所有模板
	 * @return
	 */
	@PostMapping("/getAllMouldInfo")
	@ResponseBody
	public ResultData getAllMouldInfo(HttpServletRequest request) {
		ResultData result = new ResultData();
		try {
			User user = this.getLoginUserInfo(request);
			String orgId ="";
			if(user != null && !StringUtils.isBlank(user.getBaseOrgId())){
				orgId = user.getBaseOrgId();
			}

			List<TMouldInfo> list = tMouldInfoService.getAllMouldInfo();
			Iterator<TMouldInfo> iterator = list.iterator();
			while (iterator.hasNext()){
				TMouldInfo mould = iterator.next();
				if(mould.getType() == 1 || mould.getType() == 3 || mould.getType() == 11  || mould.getType() == 21){
					iterator.remove();
				}
				//信通公司有挂职轮岗，没有员工流动，宣城和宁国公司有员工流动没有挂职轮岗
				if("10342674".equals(orgId)){
					if(mould.getType() == 20 ){
						iterator.remove();
					}
				}else{
					if(mould.getType() == 19 ){
						iterator.remove();
					}
				}
			}
			result.setData(list);
		} catch (Exception ex) {
			ex.printStackTrace();
			result.setErrorMsg("获取模板信息失败");
		}
		return result;
	}

	/**
	 * 根据模板类型以及ID删除数据
	 * @return
	 */
	@PostMapping("/deleteTempDataInfoById")
	@ResponseBody
	public ResultData deleteTempDataInfoById(@RequestParam String easyName,@RequestParam String id) {
		ResultData result = new ResultData();
		try {
			humanDataTempService.deleteTempDataInfoById(easyName,id);
			result.setData("删除成功");
		} catch (Exception ex) {
			ex.printStackTrace();
			result.setErrorMsg("获取模板信息失败");
		}
		return result;
	}

	/**
	 * 根据模板的不同获取对应表头
	 */
	@PostMapping("/getHeadByMould")
	@ResponseBody
	public ResultData getHeadByMould(@RequestParam String easyName){
		ResultData result = new ResultData();
		if(StringUtils.isBlank(easyName)){
			result.setData("参数不能为空");
		}else{
			String data = null;
			switch (easyName){
				case "jbxx":
					data = jbxx;
					break;
				case "xlxx":
					data = xlxx;
					break;
				case "gzjl":
					data = gzjl;
					break;
				case "pxsk":
					data = pxsk;
					break;
				case "grry":
					data = grry;
					break;
				case "jsks":
					data = jsks;
					break;
				case "zjrc":
					data = zjrc;
					break;
				case "zyzg":
					data = zyzg;
					break;
				case "jndj":
					data = jndj;
					break;
				case "dsdt":
					data = dsdt;
					break;
				case "ndjx":
					data = ndjx;
					break;
				case "xscg":
					data = xscg;
					break;
				case "zdbz":
					data = zdbz;
					break;
				case "zlxx":
					data = zlxx;
					break;
				case "jygx":
					data = jygx;
					break;
				case "kjcx":
					data = kjcx;
					break;
				case "ktcg":
					data = ktcg;
					break;
				case "ygld":
					data = ygld;
					break;
				case "gzlg":
					data = gzlg;
					break;
				case "jxjf":
					data = jxjf;
					break;
			}
			data = data.replace("&quot;","\"").replaceAll("\\\\","");
			JSONArray jsonArray=JSONArray.fromObject(data);
			List<HeadVo> list = JSON.parseArray(jsonArray.toString(),HeadVo.class);
			result.setData(list);
		}
		return  result;
	}

	/**
	 * 数据导入模块查询列表
	 */
	@PostMapping("/getTempPageList")
	@ResponseBody
	public ResultData getTempPageList(HttpServletRequest request,@RequestParam Integer pageSize,@RequestParam Integer pageNo,@RequestParam String easyName,@RequestParam String userName,@RequestParam String erpNo){
		ResultData result = new ResultData();
		User user = this.getLoginUserInfo(request);
		if(StringUtils.isBlank(easyName)){
			result.setData("获取参数失败");
		}else{
			switch (easyName){
				case "jbxx"://基本信息临时数据
					Page<TEmpBaseInfoTemp> page1 = new Page<TEmpBaseInfoTemp>();
					page1.setPageNo(pageNo);
					page1.setPageSize(pageSize);
					humanDataTempService.getTEmpBaseInfoTempPageList(page1,userName,erpNo,user.getBaseOrgId());
					page1.getResult().forEach(p ->{
						p.setNation(SysDictionaryUtil.getNameByValueForDefault("Nation",p.getNation()));
						p.setSex(SysDictionaryUtil.getNameByValueForDefault("Gender",p.getSex()));
						p.setPolitiStatus(SysDictionaryUtil.getNameByValueForDefault("PoliticalLandscapeText",p.getPolitiStatus()));
						p.setEasyName("jbxx");
					});
					result.setData(page1);
					break;
				case "xlxx"://学历信息临时数据
					Page<TEducateInfoTemp> page2 = new Page<TEducateInfoTemp>();
					page2.setPageNo(pageNo);
					page2.setPageSize(pageSize);
					humanDataTempService.getTEducateInfoTempPageList(page2,userName,erpNo,user.getBaseOrgId());
					page2.getResult().forEach(p ->{
						p.setSchoolType(SysDictionaryUtil.getNameByValueForDefault("CollegeCategory",p.getSchoolType()));//院校类别
						p.setEducName(SysDictionaryUtil.getNameByValueForDefault("PersonnelQualifications",p.getEducName()));//学历名称
						p.setDegreeName(SysDictionaryUtil.getNameByValueForDefault("AcademicDegree",p.getDegreeName()));//学位名称
						p.setEasyName("xlxx");
					});
					result.setData(page2);
					break;
				case "gzjl"://工作经历临时数据
					Page<TWorkExpInfoTemp> page3 = new Page<TWorkExpInfoTemp>();
					page3.setPageNo(pageNo);
					page3.setPageSize(pageSize);
					humanDataTempService.getTWorkExpInfoTempPageList(page3,userName,erpNo,user.getBaseOrgId());
					page3.getResult().forEach(p ->{
						p.setRank(SysDictionaryUtil.getNameByValueForDefault("DutyLevel",p.getRank()));//级别
						p.setPostType(SysDictionaryUtil.getNameByValueForDefault("PostCategory",p.getPostType()));//岗位类别
						p.setEasyName("gzjl");
					});
					result.setData(page3);
					break;
				case "pxsk"://继续教育及培训信息临时数据
					Page<TContiStudyInfoTemp> page4 = new Page<TContiStudyInfoTemp>();
					page4.setPageNo(pageNo);
					page4.setPageSize(pageSize);
					humanDataTempService.getTContiStudyInfoTempPageList(page4,userName,erpNo,user.getBaseOrgId());
					page4.getResult().forEach(p ->{
						p.setType(SysDictionaryUtil.getNameByValueForDefault("PeixunshoukeType",p.getType()));//类别
						p.setEasyName("pxsk");
					});
					result.setData(page4);
					break;
				case "grry"://个人荣誉临时数据
					Page<THonorInfoTemp> page5 = new Page<THonorInfoTemp>();
					page5.setPageNo(pageNo);
					page5.setPageSize(pageSize);
					humanDataTempService.getTHonorInfoTempPageList(page5,userName,erpNo,user.getBaseOrgId());
					page5.getResult().forEach(p ->{
						p.setHonorLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",p.getHonorLevel()));
						p.setHonorType(SysDictionaryUtil.getNameByValueForDefault("RuYuLeiBie",p.getHonorType()));
						p.setEasyName("grry");
					});
					result.setData(page5);
					break;
				case "jsks"://竞赛考试临时数据
					Page<TContestInfoTemp> page6 = new Page<TContestInfoTemp>();
					page6.setPageNo(pageNo);
					page6.setPageSize(pageSize);
					humanDataTempService.getTContestInfoTempPageList(page6,userName,erpNo,user.getBaseOrgId());
					page6.getResult().forEach(p ->{
						p.setAwardLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",p.getAwardLevel()));//竞赛考试获奖级别
						p.setCompRank(SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj",p.getCompRank()));//竞赛考试名次
						if(p.getGetTitle().equals("0")){
							p.setGetTitle("是");
						}else{
							p.setGetTitle("否");
						}
						p.setEasyName("jsks");
					});
					result.setData(page6);
					break;
				case "zjrc"://专家人才临时数据
					Page<TExpertTitleInfoTemp> page7 = new Page<TExpertTitleInfoTemp>();
					page7.setPageNo(pageNo);
					page7.setPageSize(pageSize);
					humanDataTempService.getTExpertTitleInfoTempPageList(page7,userName,erpNo,user.getBaseOrgId());
					page7.getResult().forEach(p ->{
						p.setLevelName(SysDictionaryUtil.getNameByValueForDefault("ExpertLevel",p.getLevelName()));//等级
						p.setType(SysDictionaryUtil.getNameByValueForDefault("ExpertCategory",p.getType()));//类别
						p.setMajor(SysDictionaryUtil.getNameByValueForDefault("ProWorkTypes",p.getMajor()));//专业
						p.setEmpTitle(SysDictionaryUtil.getNameByValueForDefault("TalentTitle",p.getEmpTitle()));//专家人才称号
						p.setEasyName("zjrc");
					});
					result.setData(page7);
					break;
				case "zyzg"://专业资格临时数据
					Page<TProTecInfoTemp> page8 = new Page<TProTecInfoTemp>();
					page8.setPageNo(pageNo);
					page8.setPageSize(pageSize);
					humanDataTempService.getTProTecInfoTempPageList(page8,userName,erpNo,user.getBaseOrgId());
					page8.getResult().forEach(p ->{
						p.setSubjSet(SysDictionaryUtil.getNameByValueForDefault("ProTechnicalQualifications",p.getSubjSet()));
						p.setSubjLevel(SysDictionaryUtil.getNameByValueForDefault("ProfessionalQualifications",p.getSubjLevel()));
						p.setOrgLevel(SysDictionaryUtil.getNameByValueForDefault("IdentificationUnitLevel",p.getOrgLevel()));
						p.setEasyName("zyzg");
					});
					result.setData(page8);
					break;
				case "jndj"://技能等级临时数据
					Page<TSkillLevelInfoTemp> page9 = new Page<TSkillLevelInfoTemp>();
					page9.setPageNo(pageNo);
					page9.setPageSize(pageSize);
					humanDataTempService.getTSkillLevelInfoTempPageList(page9,userName,erpNo,user.getBaseOrgId());
					page9.getResult().forEach(p ->{
						p.setTechType(SysDictionaryUtil.getNameByValueForDefault("SkillAppraisalWork",p.getTechType()));//技能鉴定工种
						p.setQualifiLevel(SysDictionaryUtil.getNameByValueForDefault("QualificationLevel",p.getQualifiLevel()));//职业资格等级
						p.setOrgLevel(SysDictionaryUtil.getNameByValueForDefault("IdentificationUnitLevel",p.getOrgLevel()));//发证单位级别
						p.setEasyName("jndj");
					});
					result.setData(page9);
					break;
				case "dsdt"://导师带徒临时数据
					Page<TSdtTutorPrentInfoTemp> page10 = new Page<TSdtTutorPrentInfoTemp>();
					page10.setPageNo(pageNo);
					page10.setPageSize(pageSize);
					humanDataTempService.getTSdtTutorPrentInfoTempPageList(page10,userName,erpNo,user.getBaseOrgId());
					page10.getResult().forEach(p ->{
						p.setEasyName("dsdt");
					});
					//连表查询时总条数获取错误，所以用该方法暂时获取总条数
					Page<TSdtTutorPrentInfoTemp> page00 = new Page<TSdtTutorPrentInfoTemp>();
					page00.setPageSize(1000);
					page00.setPageNo(1);
					humanDataTempService.getTSdtTutorPrentInfoTempPageList(page00,userName,erpNo,user.getBaseOrgId());
					if(page00 != null && page00.getResult() != null && page00.getResult().size() > 0){
						page10.setTotalCount(page00.getResult().size());
					}
					result.setData(page10);
					break;
				case "ndjx"://年度绩效临时数据
					Page<TYearEffectInfoTemp> page11 = new Page<TYearEffectInfoTemp>();
					page11.setPageNo(pageNo);
					page11.setPageSize(pageSize);
					humanDataTempService.getTYearEffectInfoTempPageList(page11,userName,erpNo,user.getBaseOrgId());
					page11.getResult().forEach(p ->{
						p.setPerforGrade(SysDictionaryUtil.getNameByValueForDefault("PerformLevelRecentThreeYears",p.getPerforGrade()));//绩效等级
						p.setEasyName("ndjx");
					});
					result.setData(page11);
					break;
				case "xscg"://学术成果临时数据
					Page<TAcadeAchiveInfoTemp> page12 = new Page<TAcadeAchiveInfoTemp>();
					page12.setPageNo(pageNo);
					page12.setPageSize(pageSize);
					humanDataTempService.getTAcadeAchiveInfoTempPageList(page12,userName,erpNo,user.getBaseOrgId());
					page12.getResult().forEach(p ->{
						p.setLevel(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJb",p.getLevel()));//级别
						p.setAcadType(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoType",p.getAcadType()));//类别
						p.setEasyName("xscg");
					});
					//连表查询时总条数获取错误，所以用该方法暂时获取总条数
					Page<TAcadeAchiveInfoTemp> page01 = new Page<TAcadeAchiveInfoTemp>();
					page01.setPageSize(1000);
					page01.setPageNo(1);
					humanDataTempService.getTAcadeAchiveInfoTempPageList(page01,userName,erpNo,user.getBaseOrgId());
					if(page01 != null && page01.getResult() != null && page01.getResult().size() > 0){
						page12.setTotalCount(page01.getResult().size());
					}
					result.setData(page12);
					break;
				case "zdbz"://制度标准临时数据
					Page<TStandInfoTemp> page13 = new Page<TStandInfoTemp>();
					page13.setPageNo(pageNo);
					page13.setPageSize(pageSize);
					humanDataTempService.getTStandInfoTempPageList(page13,userName,erpNo,user.getBaseOrgId());
					page13.getResult().forEach(p ->{
						p.setType(SysDictionaryUtil.getNameByValueForDefault("ZdbzType",p.getType()));//类别
						p.setLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",p.getLevel()));//级别
						p.setEasyName("zdbz");
					});
					//连表查询时总条数获取错误，所以用该方法暂时获取总条数
					Page<TStandInfoTemp> page02 = new Page<TStandInfoTemp>();
					page02.setPageSize(1000);
					page02.setPageNo(1);
					humanDataTempService.getTStandInfoTempPageList(page02,userName,erpNo,user.getBaseOrgId());
					if(page02 != null && page02.getResult() != null && page02.getResult().size() > 0){
						page13.setTotalCount(page02.getResult().size());
					}
					result.setData(page13);
					break;
				case "zlxx"://专利临时数据
					Page<TPatentInfoTemp> page14 = new Page<TPatentInfoTemp>();
					page14.setPageNo(pageNo);
					page14.setPageSize(pageSize);
					humanDataTempService.getTPatentInfoTempPageList(page14,userName,erpNo,user.getBaseOrgId());
					page14.getResult().forEach(p ->{
						p.setPatentType(SysDictionaryUtil.getNameByValueForDefault("PatentType",p.getPatentType()));//类别
						p.setEasyName("zlxx");
					});
					//连表查询时总条数获取错误，所以用该方法暂时获取总条数
					Page<TPatentInfoTemp> page03 = new Page<TPatentInfoTemp>();
					page03.setPageSize(1000);
					page03.setPageNo(1);
					humanDataTempService.getTPatentInfoTempPageList(page03,userName,erpNo,user.getBaseOrgId());
					if(page03 != null && page03.getResult() != null && page03.getResult().size() > 0){
						page14.setTotalCount(page03.getResult().size());
					}
					result.setData(page14);
					break;
				case "jygx"://技艺革新临时数据
					Page<TTecInnovInfoTemp> page15 = new Page<TTecInnovInfoTemp>();
					page15.setPageNo(pageNo);
					page15.setPageSize(pageSize);
					humanDataTempService.getTTecInnovInfoTempPageList(page15,userName,erpNo,user.getBaseOrgId());
					page15.getResult().forEach(p ->{
						p.setAwardLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",p.getAwardLevel()));//QC获奖级别
						p.setAwardGrade(SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj",p.getAwardGrade()));//奖项等级
						p.setEasyName("jygx");
					});
					//连表查询时总条数获取错误，所以用该方法暂时获取总条数
					Page<TTecInnovInfoTemp> page04 = new Page<TTecInnovInfoTemp>();
					page04.setPageSize(1000);
					page04.setPageNo(1);
					humanDataTempService.getTTecInnovInfoTempPageList(page04,userName,erpNo,user.getBaseOrgId());
					if(page04 != null && page04.getResult() != null && page04.getResult().size() > 0){
						page15.setTotalCount(page04.getResult().size());
					}
					result.setData(page15);
					break;
				case "kjcx"://科技创新临时数据
					Page<TTecManInnovTemp> page16 = new Page<TTecManInnovTemp>();
					page16.setPageNo(pageNo);
					page16.setPageSize(pageSize);
					humanDataTempService.getTTecManInnovTempPageList(page16,userName,erpNo,user.getBaseOrgId());
					page16.getResult().forEach(p ->{
						p.setAwardLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",p.getAwardLevel()));//获奖级别
						p.setAwardGrade(SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj",p.getAwardGrade()));//奖项等级
						p.setAchiType(SysDictionaryUtil.getNameByValueForDefault("KjglAchiveType",p.getAchiType()));//成果类别
						p.setEasyName("kjcx");
					});
					//连表查询时总条数获取错误，所以用该方法暂时获取总条数
					Page<TTecManInnovTemp> page05 = new Page<TTecManInnovTemp>();
					page05.setPageSize(1000);
					page05.setPageNo(1);
					humanDataTempService.getTTecManInnovTempPageList(page05,userName,erpNo,user.getBaseOrgId());
					if(page05 != null && page05.getResult() != null && page05.getResult().size() > 0){
						page16.setTotalCount(page05.getResult().size());
					}
					result.setData(page16);
					break;
				case "ktcg"://课题成果临时数据
					Page<TProjAchieveInfoTemp> page17 = new Page<TProjAchieveInfoTemp>();
					page17.setPageNo(pageNo);
					page17.setPageSize(pageSize);
					humanDataTempService.getTProjAchieveInfoTempPageList(page17,userName,erpNo,user.getBaseOrgId());
					page17.getResult().forEach(p ->{
						p.setProjLevel(SysDictionaryUtil.getNameByValueForDefault("StandardLevel",p.getProjLevel()));
						p.setEasyName("ktcg");
					});
					//连表查询时总条数获取错误，所以用该方法暂时获取总条数
					Page<TProjAchieveInfoTemp> page06 = new Page<TProjAchieveInfoTemp>();
					page06.setPageSize(1000);
					page06.setPageNo(1);
					humanDataTempService.getTProjAchieveInfoTempPageList(page06,userName,erpNo,user.getBaseOrgId());
					if(page06 != null && page06.getResult() != null && page06.getResult().size() > 0){
						page17.setTotalCount(page06.getResult().size());
					}
					result.setData(page17);
					break;
				case "ygld"://员工流动临时数据
					Page<TEmployeeMobilityTemp> page18 = new Page<TEmployeeMobilityTemp>();
					page18.setPageNo(pageNo);
					page18.setPageSize(pageSize);
					humanDataTempService.getTEmployeeMobilityTempPageList(page18,userName,erpNo,user.getBaseOrgId());
					page18.getResult().forEach(p ->{
						p.setFlowMode(SysDictionaryUtil.getNameByValueForDefault("FlowMode",p.getFlowMode()));
						p.setFlowType(SysDictionaryUtil.getNameByValueForDefault("FlowType",p.getFlowType()));
						p.setFlowArea(SysDictionaryUtil.getNameByValueForDefault("FlowArea",p.getFlowArea()));
						p.setEasyName("ygld");
					});
					result.setData(page18);
					break;
				case "gzlg"://挂职轮岗临时数据
					Page<TRotationInfoTemp> page19 = new Page<TRotationInfoTemp>();
					page19.setPageNo(pageNo);
					page19.setPageSize(pageSize);
					humanDataTempService.getTRotationInfoTempPageList(page19,userName,erpNo,user.getBaseOrgId());
					page19.getResult().forEach(p ->{
						p.setEasyName("gzlg");
					});
					result.setData(page19);
					break;
				case "jxjf"://绩效积分临时数据
					Page<TPerformanceScoreTemp> page20 = new Page<TPerformanceScoreTemp>();
					page20.setPageNo(pageNo);
					page20.setPageSize(pageSize);
					humanDataTempService.getTPerformanceScoreTempPageList(page20,userName,erpNo,user.getBaseOrgId());
					page20.getResult().forEach(p ->{
						p.setPerforGrade(SysDictionaryUtil.getNameByValueForDefault("PerformLevelRecentThreeYears",p.getPerforGrade()));
						p.setEasyName("jxjf");
					});
					result.setData(page20);
					break;
			}
		}
		return result;
	}

	/**
	 * 根据类型和id获取单条数据
	 */
	@PostMapping("/getSingleTempDataByTypeAndId")
	@ResponseBody
	public ResultData getSingleTempDataByTypeAndId(@RequestParam String easyName,@RequestParam String id){
		ResultData result = new ResultData();
		if(StringUtils.isBlank(easyName)){
			result.setData("参数不能为空");
		}else{
			switch (easyName){
				case "jbxx":
					TEmpBaseInfoTemp tEmpBaseInfoTemp = humanDataTempService.getTEmpBaseInfoTempById(id);
					result.setData(tEmpBaseInfoTemp);
					break;
				case "xlxx":
					TEducateInfoTemp tEducateInfoTemp = humanDataTempService.getTEducateInfoTempById(id);
					result.setData(tEducateInfoTemp);
					break;
				case "gzjl":
					TWorkExpInfoTemp tWorkExpInfoTemp = humanDataTempService.getTWorkExpInfoTempById(id);
					result.setData(tWorkExpInfoTemp);
					break;
				case "pxsk":
					TContiStudyInfoTemp tContiStudyInfoTemp = humanDataTempService.getTContiStudyInfoTempById(id);
					result.setData(tContiStudyInfoTemp);
					break;
				case "grry":
					THonorInfoTemp tHonorInfoTemp = humanDataTempService.getTHonorInfoTempById(id);
					result.setData(tHonorInfoTemp);
					break;
				case "jsks":
					TContestInfoTemp tContestInfoTemp = humanDataTempService.getTContestInfoTempById(id);
					result.setData(tContestInfoTemp);
					break;
				case "zjrc":
					TExpertTitleInfoTemp tExpertTitleInfoTemp = humanDataTempService.getTExpertTitleInfoTempById(id);
					result.setData(tExpertTitleInfoTemp);
					break;
				case "zyzg":
					TProTecInfoTemp tProTecInfoTemp = humanDataTempService.getTProTecInfoTempById(id);
					result.setData(tProTecInfoTemp);
					break;
				case "jndj":
					TSkillLevelInfoTemp tSkillLevelInfoTemp = humanDataTempService.getTSkillLevelInfoTempById(id);
					result.setData(tSkillLevelInfoTemp);
					break;
				case "dsdt":
					TSdtTutorPrentInfoTemp tSdtTutorPrentInfoTemp = humanDataTempService.getTSdtTutorPrentInfoTempById(id);
					result.setData(tSdtTutorPrentInfoTemp);
					break;
				case "ndjx":
					TYearEffectInfoTemp tYearEffectInfoTemp = humanDataTempService.getTYearEffectInfoTempById(id);
					result.setData(tYearEffectInfoTemp);
					break;
				case "xscg":
					TAcadeAchiveInfoTemp tAcadeAchiveInfoTemp = humanDataTempService.getTAcadeAchiveInfoTempById(id);
					result.setData(tAcadeAchiveInfoTemp);
					break;
				case "zdbz":
					TStandInfoTemp tStandInfoTemp = humanDataTempService.getTStandInfoTempById(id);
					result.setData(tStandInfoTemp);
					break;
				case "zlxx":
					TPatentInfoTemp tPatentInfoTemp = humanDataTempService.getTPatentInfoTempById(id);
					result.setData(tPatentInfoTemp);
					break;
				case "jygx":
					TTecInnovInfoTemp tTecInnovInfoTemp = humanDataTempService.getTTecInnovInfoTempById(id);
					result.setData(tTecInnovInfoTemp);
					break;
				case "kjcx":
					TTecManInnovTemp tTecManInnovTemp = humanDataTempService.getTTecManInnovTempById(id);
					result.setData(tTecManInnovTemp);
					break;
				case "ktcg":
					TProjAchieveInfoTemp tProjAchieveInfoTemp = humanDataTempService.getTProjAchieveInfoTempById(id);
					result.setData(tProjAchieveInfoTemp);
					break;
				case "ygld":
					TEmployeeMobilityTemp tEmployeeMobilityTemp = humanDataTempService.getTEmployeeMobilityTempById(id);
					result.setData(tEmployeeMobilityTemp);
					break;
				case "gzlg":
					TRotationInfoTemp tRotationInfoTemp = humanDataTempService.getTRotationInfoTempById(id);
					result.setData(tRotationInfoTemp);
					break;
				case "jxjf":
					TPerformanceScoreTemp tPerformanceScoreTemp = humanDataTempService.getTPerformanceScoreTempById(id);
					result.setData(tPerformanceScoreTemp);
					break;
			}
		}
		return  result;
	}


	/*******************************临时数据添加或修改*****************************************/

	/**
	 * 添加人资基本信息
	 *
	 * @param baseInfo
	 * @return
	 */
	@RequestMapping("/addBaseInfo")
	@ResponseBody
	public ResultData addBaseInfo(TEmpBaseInfoTemp baseInfo) {
		ResultData rs = new ResultData();
		// 由于有附件，主键id由前端生成
		try {
			humanDataTempService.updateBaseInfoTempById(baseInfo);
			rs.setData("人资基本信息保存成功！");
			LOG.info("人资基本信息保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("人资基本信息保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加学历信息
	 *
	 * @param tEducateInfo
	 * @return
	 */
	@RequestMapping("/addEducateInfo")
	@ResponseBody
	public ResultData addEducateInfo(TEducateInfoTemp tEducateInfo) {
		ResultData rs = new ResultData();
		try {
			humanDataTempService.updateTEducateInfoTempById(tEducateInfo);
			rs.setData("学历信息保存成功！");
			LOG.info("学历信息保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("学历信息保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加工作经历
	 *
	 * @param tWorkExpInfo
	 * @return
	 */
	@RequestMapping("/addWorkExpInfo")
	@ResponseBody
	public ResultData addWorkExpInfo(TWorkExpInfoTemp tWorkExpInfo) {
		ResultData rs = new ResultData();
		try {
			humanDataTempService.updateTWorkExpInfoTempById(tWorkExpInfo);
			rs.setData("工作经历保存成功！");
			LOG.info("工作经历保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("工作经历保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 培训经历、授课经历
	 *
	 * @param tContiStudyInfo
	 * @return
	 */
	@RequestMapping("/addContiStudyInfo")
	@ResponseBody
	public ResultData addContiStudyInfo(TContiStudyInfoTemp tContiStudyInfo) {
		ResultData rs = new ResultData();
		try {
			humanDataTempService.updateTContiStudyInfoTempById(tContiStudyInfo);
			rs.setData("继续教育经历、培训经历、授课经历保存成功！");
			LOG.info("继续教育经历、培训经历、授课经历保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("继续教育经历、培训经历、授课经历保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加个人荣誉信息
	 *
	 * @param tHonorInfo
	 * @return
	 */
	@RequestMapping("/addHonorInfo")
	@ResponseBody
	public ResultData addHonorInfo(THonorInfoTemp tHonorInfo) {
		ResultData rs = new ResultData();
		try {
			humanDataTempService.updateTHonorInfoTempById(tHonorInfo);
			rs.setData("个人荣誉信息保存成功！");
			LOG.info("个人荣誉信息保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("个人荣誉信息保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加竞赛考试
	 *
	 * @param tContestInfo
	 * @return
	 */
	@RequestMapping("/addContestInfo")
	@ResponseBody
	public ResultData addContestInfo(TContestInfoTemp tContestInfo) {
		ResultData rs = new ResultData();
		try {
			humanDataTempService.updateTContestInfoTempById(tContestInfo);
			rs.setData("竞赛考试保存成功！");
			LOG.info("竞赛考试保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("竞赛考试保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加专家人才称号信息
	 *
	 * @param tExpertTitleInfo
	 * @return
	 */
	@RequestMapping("/addExpertTitleInfo")
	@ResponseBody
	public ResultData addExpertTitleInfo(TExpertTitleInfoTemp tExpertTitleInfo) {
		ResultData rs = new ResultData();
		try {
			humanDataTempService.updateTExpertTitleInfoTempById(tExpertTitleInfo);
			rs.setData("专家人才称号信息保存成功！");
			LOG.info("专家人才称号信息保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("专家人才称号信息保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加专业技术资格信息
	 *
	 * @param
	 * @return
	 */
	@RequestMapping("/addProTecInfo")
	@ResponseBody
	public ResultData addProTecInfo(TProTecInfoTemp tProTecInfo) {
		ResultData rs = new ResultData();
		try {
			humanDataTempService.updateTProTecInfoTempById(tProTecInfo);
			rs.setData("专业技术资格信息保存成功！");
			LOG.info("专业技术资格信息保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("专业技术资格信息保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加技能等级信息
	 *
	 * @param tSkillLevelInfo
	 * @return
	 */
	@RequestMapping("/addSkillLevelInfo")
	@ResponseBody
	public ResultData addSkillLevelInfo(TSkillLevelInfoTemp tSkillLevelInfo) {
		ResultData rs = new ResultData();
		try {
			humanDataTempService.updateTSkillLevelInfoTempById(tSkillLevelInfo);
			rs.setData("技能等级信息保存成功！");
			LOG.info("技能等级信息保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("技能等级信息保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加导师带徒
	 *
	 * @param
	 * @return
	 */
	@RequestMapping("/addSdtTutorPrentInfo")
	@ResponseBody
	public ResultData addSdtTutorPrentInfo(@RequestBody TSdtTutorPrentInfoTemp tSdtTutorPrentInfo,HttpServletRequest request) {
		ResultData rs = new ResultData();
		User user = this.getLoginUserInfo(request);
		try {
			humanDataTempService.updateTSdtTutorPrentInfoTempById(tSdtTutorPrentInfo,user);
			rs.setData("导师带徒保存成功！");
			LOG.info("导师带徒保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("导师带徒保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加年度绩效
	 * @param yearEffectInfo
	 * @return
	 */
	@RequestMapping("/addYearEffect")
	@ResponseBody
	public ResultData addYearEffect(TYearEffectInfoTemp yearEffectInfo) {
		ResultData rs = new ResultData();
		try {
			humanDataTempService.updateTYearEffectInfoTempById(yearEffectInfo);
			rs.setData("年度绩效保存成功！");
			LOG.info("年度绩效保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("年度绩效保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加学术成果
	 *
	 * @param tAcadeAchiveInfo
	 * @return
	 */
	@RequestMapping("/addAcadeAchiveInfo")
	@ResponseBody
	public ResultData addAcadeAchiveInfo(@RequestBody TAcadeAchiveInfoTemp tAcadeAchiveInfo,HttpServletRequest request) {
		ResultData rs = new ResultData();
		User user = this.getLoginUserInfo(request);
		try {
			humanDataTempService.updateTAcadeAchiveInfoTempById(tAcadeAchiveInfo,user);
			rs.setData("学术成果保存成功！");
			LOG.info("学术成果保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("学术成果保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加制度标准
	 *
	 * @param tStandInfo
	 * @return
	 */
	@RequestMapping("/addStandInfo")
	@ResponseBody
	public ResultData addStandInfo(@RequestBody TStandInfoTemp tStandInfo,HttpServletRequest request) {
		ResultData rs = new ResultData();
		User user = this.getLoginUserInfo(request);
		try {
			humanDataTempService.updateTStandInfoTempById(tStandInfo,user);
			rs.setData("制度标准保存成功！");
			LOG.info("制度标准保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("制度标准保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加专利
	 *
	 * @param tPatentInfo
	 * @return
	 */
	@RequestMapping("/addPatentInfo")
	@ResponseBody
	public ResultData addPatentInfo(@RequestBody TPatentInfoTemp tPatentInfo,HttpServletRequest request) {
		ResultData rs = new ResultData();
		User user = this.getLoginUserInfo(request);
		try {
			humanDataTempService.updateTPatentInfoTempById(tPatentInfo,user);
			rs.setData("专利保存成功！");
			LOG.info("专利保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("专利保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加技艺革新信息
	 *
	 * @param tTecInnovInfo
	 * @return
	 */
	@RequestMapping("/addTecInnovInfo")
	@ResponseBody
	public ResultData addTecInnovInfo(@RequestBody TTecInnovInfoTemp tTecInnovInfo,HttpServletRequest request) {
		ResultData rs = new ResultData();
		User user = this.getLoginUserInfo(request);
		try {
			humanDataTempService.updateTTecInnovInfoTempById(tTecInnovInfo,user);
			rs.setData("技艺革新信息保存成功！");
			LOG.info("技艺革新信息保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("技艺革新信息保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 添加科技及管理、创新成果
	 *
	 * @param tTecManInnov
	 * @return
	 */
	@RequestMapping("/addTecManInnov")
	@ResponseBody
	public ResultData addTecManInnov(@RequestBody TTecManInnovTemp tTecManInnov,HttpServletRequest request) {
		ResultData rs = new ResultData();
		User user = this.getLoginUserInfo(request);
		try {
			humanDataTempService.updateTTecManInnovTempById(tTecManInnov,user);
			rs.setData("科技及管理、创新成果保存成功！");
			LOG.info("科技及管理、创新成果保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("科技及管理、创新成果保存失败！");
			e.printStackTrace();
		}
		return rs;
	}


	/**
	 * 添加项目、课题、成果
	 *
	 * @param
	 * @return
	 */
	@RequestMapping("/addProjAchieveInfo")
	@ResponseBody
	public ResultData addProjAchieveInfo(@RequestBody TProjAchieveInfoTemp tProjAchieveInfo,HttpServletRequest request) {
		ResultData rs = new ResultData();
		User user = this.getLoginUserInfo(request);
		try {
			humanDataTempService.updateTProjAchieveInfoTempById(tProjAchieveInfo,user);
			rs.setData("项目课题成果保存成功！");
			LOG.info("项目课题成果保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("项目课题成果保存失败！");
			e.printStackTrace();
		}
		return rs;
	}


	/**
	 * 添加绩效积分
	 *
	 * @param tPerformanceScoreTemp
	 * @return
	 */
	@RequestMapping("/addPerformanceScoreInfo")
	@ResponseBody
	public ResultData addPerformanceScoreInfo(@RequestBody TPerformanceScoreTemp tPerformanceScoreTemp) {
		ResultData rs = new ResultData();
		try {
			humanDataTempService.updateTPerformanceScoreTempById(tPerformanceScoreTemp);
			rs.setData("绩效积分保存成功！");
			LOG.info("绩效积分保存成功！");
		} catch (Exception e) {
			rs.setSuccess(false);
			rs.setErrorMsg("绩效积分保存失败！");
			e.printStackTrace();
		}
		return rs;
	}

	/**
	 * 查询人员绩效积分信息
	 */
	@RequestMapping("/searchUserPerformanceScoreList")
	@ResponseBody
	public ResultData searchUserPerformanceScoreList(@RequestBody TPerformanceScoreVo tPerformanceScoreVo, Page<TPerformanceScoreVo> page, HttpServletRequest req) {
		ResultData result = new ResultData();
		try {
			humanDataTempService.searchPerformanceScoreList(page, tPerformanceScoreVo);
			if (!page.getResult().isEmpty()) {
				page.getResult().forEach(p -> {
					p.setPerforGradeName(SysDictionaryUtil.getNameByValueForDefault("PerformLevelRecentThreeYears", p.getPerforGrade()));// 年度绩效
				});
			}
			result.setData(page);
			LOG.info("查询人员绩效积分信息成功");
		} catch (Exception e) {
			result.setErrorMsg("查询人员绩效积分信息异常");
			result.setSuccess(false);
			LOG.error("查询人员绩效积分信息异常", e);
		}
		return result;
	}
	
}
